<?php

App::uses('AppModel', 'Model');

class User extends AppModel {

    public $hasAndBelongsToMany = array(
        'Store' => array( 'joinTable' => 'users_stores' )
    );
    
    public $hasMany = array(
         'UsersStore' => array( 'dependent' => true )
    );
    
    public $validate = array(
        'username' => array(
            'length' => array(
                'rule'    => array('custom', '/^[a-zA-z0-9_]{4,}$/'),
                'message' => 'Korisničko ime nije validno.'
            ),
            'unique' => array(
                'rule'    => 'isUnique',
                'message' => 'Korisničko ime je već zauzeto.'
            )
        )
    );

}